package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo6 {
    public static void main(String[] args) {
        try(Connection connection=DBUtil.getConnection();){
            Statement statement=connection.createStatement();
            String sql="SELECT t.name,t.salary,c.name,c.floor "+
                    "FROM teacher t "+
                    "join class c on t.id=c.teacher_id "+
                    "where t.name='王克晶'";
            ResultSet rs=statement.executeQuery(sql);
            while (rs.next()){
                String tname=rs.getString("t.name");
                int tsalary=rs.getInt("t.salary");
                String cname=rs.getString("c.name");
                int cfloor=rs.getInt("c.floor");
                //System.out.println(tname+","+tsalary+","+cname+","+cfloor);
                String line=String.join(","/*符号任意，int类型加""(空串）*/,tname,tsalary+"",cname,cfloor+"");
                System.out.println(line);
//                if(tname=username1&&tpassword=password1){
//
//                }
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
